diff options
Diffstat (limited to 'src/routes/(app)/send/invoice/[id]/+page.server.js')
| -rw-r--r-- | src/routes/(app)/send/invoice/[id]/+page.server.js | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/src/routes/(app)/send/invoice/[id]/+page.server.js b/src/routes/(app)/send/invoice/[id]/+page.server.js index c6b0a9a4..b0cbef45 100644 --- a/src/routes/(app)/send/invoice/[id]/+page.server.js +++ b/src/routes/(app)/send/invoice/[id]/+page.server.js @@ -2,35 +2,18 @@ import { error, fail, redirect } from "@sveltejs/kit"; import { fd, auth, get, post } from "$lib/utils"; export async function load({ params: { id }, parent, url }) { - let { user } = await parent(); + let { rates, user } = await parent(); - let { - amount, - address, - currency, - hash, - rate, - prompt, - tip, - text, - user: recipient, - } = await get(`/invoice/${id}`); + let invoice = await get(`/invoice/${id}`); - if (prompt && tip === null) - redirect(307, `/${recipient.username}/invoice/${id}/tip`); - if (recipient.username === user.username) + console.log("OH", invoice, invoice.prompt, invoice.tip); + + if (invoice.prompt && invoice.tip === null) + redirect(307, `/${invoice.user.username}/invoice/${id}/tip`); + if (invoice.user.username === user.username) error(500, { message: "Cannot send to self" }); - return { - amount, - address, - currency, - hash, - tip, - rate, - payreq: text, - recipient, - }; + return { invoice, rates, user }; } export const actions = { |
